]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ShellAppSystem: own the memory for the startup wm class and app id
authorGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 25 Dec 2013 19:35:13 +0000 (20:35 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Thu, 26 Dec 2013 22:44:54 +0000 (23:44 +0100)
The hash table must keep a copy of the IDs, because the GAppInfos
are unreferenced (and thus freed) at the end of the function.
This was possibly not a problem if the GAppInfos were referencing
the memory-mapped cache, but it becomes one for regularly parsed
desktop files in ~/.local.

https://bugzilla.gnome.org/show_bug.cgi?id=721039

src/shell-app-system.c

index 3a31709254ceba3d2d18a48ca4cf488ed87a072e..db31fcb9c43916310c7e5251282d81b73c6d44c6 100644 (file)
@@ -87,8 +87,13 @@ scan_startup_wm_class_to_id (ShellAppSystem *self)
 
       id = g_app_info_get_id (info);
       startup_wm_class = g_desktop_app_info_get_startup_wm_class (G_DESKTOP_APP_INFO (info));
+
       if (startup_wm_class != NULL)
-        g_hash_table_insert (priv->startup_wm_class_to_id, (char *) startup_wm_class, (char *) id);
+        {
+          g_hash_table_insert (priv->startup_wm_class_to_id,
+                               g_strdup (startup_wm_class), g_strdup (id));
+          g_debug ("Application %s has StartupWMClass %s", id, startup_wm_class);
+        }
     }
 
   g_list_free_full (apps, g_object_unref);
@@ -120,7 +125,7 @@ shell_app_system_init (ShellAppSystem *self)
                                            NULL,
                                            (GDestroyNotify)g_object_unref);
 
-  priv->startup_wm_class_to_id = g_hash_table_new (g_str_hash, g_str_equal);
+  priv->startup_wm_class_to_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 
   monitor = g_app_info_monitor_get ();
   g_signal_connect (monitor, "changed", G_CALLBACK (installed_changed), self);